package com.mdxx.xczd.db.dao;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import com.mdxx.xczd.bean.ImageBean;
import com.mdxx.xczd.bean.Point;

import java.util.ArrayList;
import java.util.List;

public class PhotoServerDAO  extends ServerDAO{

	public PhotoServerDAO(Context context) {
		super(context);		
	}
	
	

	
	@Override
	public List<ImageBean> queryMulti(String sql) {
		List<ImageBean> list = new ArrayList<ImageBean>();
		ImageBean imageBean = new ImageBean();
		Point clola = new Point();
		SQLiteDatabase db = null;
		Cursor cursor;
		try {
			db = dbHelper.getWritableDatabase();
			cursor = db.rawQuery(sql, null);
			while (cursor.moveToNext()) {
				for (int i = 0; i < cursor.getColumnCount(); i++) {
					String photo = cursor.getString(cursor.getColumnIndex("photo"));
					String ptime = cursor.getString(cursor.getColumnIndex("ptime"));
					double lo = cursor.getDouble(cursor.getColumnIndex("lo"));
					double la = cursor.getDouble(cursor.getColumnIndex("la"));								
					clola.setLatitude(la);
					clola.setLongitude(lo);				
					imageBean.setClola(clola);
					imageBean.setDate(ptime);
					imageBean.setPath(photo);					
				}
				list.add(imageBean);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (null != db) {
				db.close();
			}
		}
		return list;
	}

}
